package com.sa.commons.dao.hiber.query.inter;

import java.util.List;
import java.util.Map;

import org.hibernate.Session;

import com.sa.commons.dao.hiber.util.Element;

import com.sa.commons.dao.hiber.OrderType;
import com.sa.commons.exception.DBDataErrorException;
import com.sa.commons.exception.DBErrorException;


/**
 * 查询接口
 * 
 * @author 黄欣
 *
 * @param <E>
 */
public interface GenericQuery<E>{

	
	
	/**
	 * 
	 * @param equalsMap
	 * @param inMap
	 * @param likeMap
	 * @param orderMap
	 * @param firstResult
	 * @param maxResult
	 * @return
	 * @throws DBDataErrorException 
	 */
	public List<E> findEntity(Map<String, ?> equalsMap,
			Map<String,? extends Object[]> inMap, Map<String, String> likeMap,
			Map<String, OrderType> orderMap, int firstResult, int maxResult) throws DBErrorException,DBDataErrorException;

	/**
	 * 
	 * @param equalsMap
	 * @param inMap
	 * @param orderMap
	 * @param firstResult
	 * @param maxResult
	 * @return
	 * @throws DBErrorException,DBDataErrorException 
	 */
	public List<E> findEntity(Map<String, ?> equalsMap,
			Map<String,? extends Object[]> inMap, Map<String, OrderType> orderMap,
			int firstResult, int maxResult) throws DBErrorException,DBDataErrorException;
	
	/**
	 * 
	 * @param equalsMap
	 * @return
	 */
	public List<E> findEntity(Map<String, ?> equalsMap)throws DBErrorException,DBDataErrorException;

	/**
	 * 
	 * @param equalsMap
	 * @param orderMap
	 * @param firstResult
	 * @param maxResult
	 * @return
	 * @throws DBErrorException,DBDataErrorException 
	 */
	public List<E> findEntity(Map<String, ?> equalsMap,
			Map<String, OrderType> orderMap, int firstResult, int maxResult) throws DBErrorException,DBDataErrorException;

	/**
	 * 
	 * @param equalsMap
	 * @param firstResult
	 * @param maxResult
	 * @return
	 * @throws DBErrorException,DBDataErrorException 
	 */
	public List<E> findEntity(Map<String, ?> equalsMap, int firstResult,
			int maxResult) throws DBErrorException,DBDataErrorException;

	/**
	 * 
	 * @param equalsMap
	 * @param inMap
	 * @param orderMap
	 * @param likeMap
	 * @return
	 * @throws DBErrorException,DBDataErrorException 
	 */
	public List<E> findEntity(Map<String, ?> equalsMap,
			Map<String,? extends Object[]> inMap, Map<String, String> likeMap,
			Map<String, OrderType> orderMap) throws DBErrorException,DBDataErrorException;

	/**
	 * 
	 * @param equalsMap
	 * @param inMap
	 * @param likeMap
	 * @return
	 */
	public long countEntity(Map<String, ?> equalsMap,
			Map<String,? extends Object[]> inMap, Map<String, String> likeMap)throws DBErrorException,DBDataErrorException;

	/**
	 * 
	 * @param equalsMap
	 * @param inMap
	 * @return
	 */
	public long countEntity(Map<String, ?> equalsMap,
			Map<String,? extends Object[]> inMap)throws DBErrorException,DBDataErrorException;

	/**
	 * 
	 * @param equalsMap
	 * @return
	 */
	public long countEntity(Map<String, ?> equalsMap)throws DBErrorException,DBDataErrorException;
	
	
	/**
	 * 
	 * @param elements
	 * @return
	 */
	public List findEntityByList(List<Element> elements)throws DBErrorException,DBDataErrorException;
	
	/**
	 * 查询，条件为Element方式，该元素见util包
	 * @param elements
	 * @return
	 */
	public long countEntityByList(List<Element> elements)throws DBErrorException,DBDataErrorException;
	
	/**
	 * 
	 * @param elements
	 * @param firstResult
	 * @param maxResult
	 * @return
	 */
	public List findEntityByList(List<Element> elements,int firstResult,
			int maxResult)throws DBErrorException,DBDataErrorException;
	
	
	/**
	 * 获取当前的session  
	 */
	Session getSession();
	
}
